//
//  BottomCellView.swift
//  微博
//
//  Created by mac on 15/12/19.
//  Copyright © 2015年 mac. All rights reserved.
//

import UIKit

class BottomCellView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        //设置颜色
        backgroundColor = UIColor.whiteColor()
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    @objc private func didCommentBtnClick() {
        print(__FUNCTION__)
        
        //跳转控制器
        self.loadNavgationController()?.pushViewController(CommentViewController(), animated: true)
        
    }

    private func setupUI() {
        //添加控件
        addSubview(retweetedBtn)
        addSubview(commentBtn)
        addSubview(likeBtn)
        //创建两个线视图
        let lineView1 = lineView()
        let lineView2 = lineView()
//        let lineView3 = lineView()
        
        
        addSubview(lineView1)
        addSubview(lineView2)
//        addSubview(lineView3)
        
        //添加约束
        retweetedBtn.snp_makeConstraints { (make) -> Void in
            make.top.left.bottom.equalTo(self)
        }
        commentBtn.snp_makeConstraints { (make) -> Void in
            make.top.bottom.equalTo(self)
            make.left.equalTo(retweetedBtn.snp_right)
            make.width.equalTo(retweetedBtn.snp_width)
        }
        likeBtn.snp_makeConstraints { (make) -> Void in
            make.top.bottom.equalTo(self)
            make.left.equalTo(commentBtn.snp_right)
            make.right.equalTo(self)
            make.width.equalTo(commentBtn.snp_width)
        }
        
        //添加属性值
        commentBtn.addTarget(self, action: "didCommentBtnClick", forControlEvents: .TouchUpInside)
        
        //添加线约束
        let width:CGFloat = 0.5
        lineView1.snp_makeConstraints { (make) -> Void in
            make.width.equalTo(width)
            make.left.equalTo(retweetedBtn.snp_right)
            make.height.equalTo(self.snp_height).multipliedBy(0.6)
            make.centerY.equalTo(retweetedBtn.snp_centerY)
        }
        lineView2.snp_makeConstraints { (make) -> Void in
            make.width.equalTo(width)
            make.left.equalTo(commentBtn.snp_right)
            make.height.equalTo(self.snp_height).multipliedBy(0.6)
            make.centerY.equalTo(commentBtn.snp_centerY)
        }
//        lineView3.snp_makeConstraints { (make) -> Void in
//            make.height.equalTo(width)
//            make.width.equalTo(self.snp_width)
//            make.bottom.equalTo(commentBtn.snp_top)
//            
//        }
        
    }
    
    //创建两条线视图
    private func lineView() ->UIView {
        let lineview = UIView()
        lineview.backgroundColor = UIColor.lightGrayColor()
        return lineview;
    }
    
    //懒加载控件
    private lazy var retweetedBtn:UIButton = UIButton(title: "转发", imageName: "timeline_icon_retweet", color: UIColor.lightGrayColor(), fontSize: 10, backImageName: nil)
    private lazy var commentBtn:UIButton = UIButton(title: "评论", imageName: "timeline_icon_comment", color: UIColor.lightGrayColor(), fontSize: 10, backImageName: nil)
    private lazy var likeBtn:UIButton = UIButton(title: "赞", imageName: "timeline_icon_unlike", color: UIColor.lightGrayColor(), fontSize: 10, backImageName: nil)
    
}
